package hesso.smartdraw.ch.model;

import java.util.ArrayList;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

public class Wall implements Parcelable{

	private int id = 0;
	private String name = "default";
	private float x1 = 0;
	private float y1 = 0;
	private float x2 = 0;
	private float y2 = 0;
	private int height = 0;
	private int depth = 0;
	private int wallType = 0;
	private ArrayList<Installed> installed = new ArrayList<Installed>();
	
	public Wall(float x1, float y1, float x2, float y2, int height, int detph) {
		this.x1 = x1;
		this.y1 = y1;
		this.x2 = x2;
		this.y2 = y2;
		this.height = height;
		this.depth = detph;
	}
	
	public Wall(int id, String name){
		this.id = id;
		this.name = name;
	}
	
	public Wall(){
		
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public float getX1() {
		return x1;
	}

	public void setX1(float x1) {
		this.x1 = x1;
	}

	public float getY1() {
		return y1;
	}

	public void setY1(float y1) {
		this.y1 = y1;
	}

	public float getX2() {
		return x2;
	}

	public void setX2(float x2) {
		this.x2 = x2;
	}

	public float getY2() {
		return y2;
	}

	public void setY2(float y2) {
		this.y2 = y2;
	}

	public void setPosition(float x1, float y1, float x2, float y2){
		setX1(x1);
		setX2(x2);
		setY1(y1);
		setY2(y2);
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getDepth() {
		return depth;
	}

	public void setDepth(int depth) {
		this.depth = depth;
	}

	public int getWallType() {
		return wallType;
	}

	public void setWallType(int wallType) {
		this.wallType = wallType;
	}

	public ArrayList<Installed> getInstalledArray() {
		return installed;
	}

	public void setInstalledArray(ArrayList<Installed> installed) {
		this.installed = installed;
	}
	
	public void addInstalled(Installed installed) {
		this.installed.add(installed);
	}
	
	public void removeInstalled(Installed installed) {
		this.installed.remove(installed);
	}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int arg1) {
    	Log.d("tryout", "write wall Parcel");
		dest.writeInt(id);
		dest.writeString(name);
		dest.writeFloat(x1);
		dest.writeFloat(x2);
		dest.writeFloat(y1);
		dest.writeFloat(y2);
		dest.writeInt(height);
		dest.writeInt(depth);		
    	Log.d("tryout", "wall Parcel written");
	}
	
	public static final Parcelable.Creator<Wall> CREATOR = new Parcelable.Creator<Wall>() {
		@Override
		public Wall createFromParcel(Parcel source) {
			// TODO Auto-generated method stub
			return new Wall(source);
		}

		@Override
		public Wall[] newArray(int size) {
			// TODO Auto-generated method stub
			return new Wall[size];
		}		
	};
	
	private Wall(final Parcel in){
		readFromParcel(in);
	}
	
	public void readFromParcel(final Parcel in){
		id = in.readInt();
		name = in.readString();
		x1 = in.readFloat();
		x2 = in.readFloat();
		y1 = in.readFloat();
		y2 = in.readFloat();
		height = in.readInt();
		depth = in.readInt();		
	}
}